import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
import fire from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
import s_get from '@dfeidao/atom-web/storage/get';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';


// 删除
export default async function a001(fd: IFeidaoAiBrowserComponent) {
	const _id = get(fd, '_id');
	const formgroup_no = get(fd, '_no');
	// const name = get(fd, 'name');

	const productid = await s_get('productid');
	if (!formgroup_no) {
		error("请选择一行数据");
		return;
	}

	const find_res = await nodejs('functional-permissions/zj-000001/s002', { productid, formgroup_no });
	if (find_res[0].length === 0) {
		const del_res = await nodejs('functional-permissions/zj-000001/s003', { _id, productid, formgroup_no });
		if (del_res === 'success') {
			success("删除成功");
			set(fd, '_no', 0);
			fire('zj-000001', 'ec-001');
			fire('zj-000002', 'ec-003');
		} else {
			error("删除失败");

		}
	} else {
		fd.data.node.querySelector<HTMLDivElement>('.tankuang1').classList.remove('display-n');
	}
}
